package com.dbb.trade.entity;

import java.io.File;
import java.util.Date;

import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

import com.dbb.trade.util.FileUtils;

@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(
    name="filetype",
    discriminatorType=DiscriminatorType.STRING
)
@DiscriminatorValue("base")
@Table(name = "T_FILE_RESOURCE")
public class FileResource extends IdEntity {
    private String fileName;
    private String filePath;
    private String contentType;
	private Long fileSize; 
	private Date lastModifyDate; 
    
    public FileResource() {
    }
    public FileResource(File file) {
    	this.contentType = FileUtils.getFileContent(file);
    	this.fileSize = file.length();
    	this.filePath = file.getAbsolutePath();
    	this.lastModifyDate = FileUtils.getLastModifyDate(file);
    }
    
	public String getFilePath() {
		return filePath;
	}
	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
	public String getContentType() {
		return contentType;
	}
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	public Long getFileSize() {
		return fileSize;
	}
	public void setFileSize(Long fileSize) {
		this.fileSize = fileSize;
	}
	public Date getLastModifyDate() {
		return lastModifyDate;
	}
	public void setLastModifyDate(Date lastModifyDate) {
		this.lastModifyDate = lastModifyDate;
	}

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }
}
